//
//  KRLGradientView.m
//  KaraLive
//
//  Created by Zhijia Zhong on 2018/9/15.
//  Copyright © 2018年 naxigoren. All rights reserved.
//

#import "KRLGradientView.h"

@implementation KRLGradientView

@dynamic colors;
@dynamic startPoint;
@dynamic endPoint;

+ (Class)layerClass {
    return [CAGradientLayer class];
}

- (void)setColors:(NSArray<UIColor *> *)colors {
    CAGradientLayer *gradientLayer = (CAGradientLayer *)self.layer;
    NSMutableArray *CGColors = [NSMutableArray array];
    [colors enumerateObjectsUsingBlock:^(UIColor * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [CGColors addObject:(__bridge id)obj.CGColor];
    }];
    gradientLayer.colors = CGColors;
}

- (void)setStartPoint:(CGPoint)startPoint {
    CAGradientLayer *gradientLayer = (CAGradientLayer *)self.layer;
    gradientLayer.startPoint = startPoint;
}

- (void)setEndPoint:(CGPoint)endPoint {
    CAGradientLayer *gradientLayer = (CAGradientLayer *)self.layer;
    gradientLayer.endPoint = endPoint;
}

@end
